﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace QQMusic.Controls
{
    public class BorderButton : Button
    {
        public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(BorderButton), new PropertyMetadata(""));

        /// <summary>
        /// 文字
        /// </summary>
        [Description("文本"), Category("WzxSkin")]
        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        public static readonly DependencyProperty Text2Property = DependencyProperty.Register("Text2", typeof(string), typeof(BorderButton), new PropertyMetadata(""));

        /// <summary>
        /// 文字
        /// </summary>
        [Description("文本"), Category("WzxSkin")]
        public string Text2
        {
            get { return (string)GetValue(Text2Property); }
            set { SetValue(Text2Property, value); }
        }

        public static readonly DependencyProperty ImageProperty = DependencyProperty.Register("Image", typeof(Geometry), typeof(BorderButton), new PropertyMetadata(null));

        /// <summary>
        /// 图标
        /// </summary>
        [Description("图标"), Category("WzxSkin")]
        public Geometry Image
        {
            get { return (Geometry)GetValue(ImageProperty); }
            set { SetValue(ImageProperty, value); }
        }

        public static readonly DependencyProperty ImageWidthProperty = DependencyProperty.Register("ImageWidth", typeof(double), typeof(BorderButton), new PropertyMetadata(16.0));

        /// <summary>
        /// 图标宽度
        /// </summary>
        public double ImageWidth
        {
            get { return (double)GetValue(ImageWidthProperty); }
            set { SetValue(ImageWidthProperty, value); }
        }

        public static readonly DependencyProperty ImageHeightProperty = DependencyProperty.Register("ImageHeight", typeof(double), typeof(BorderButton), new PropertyMetadata(16.0));

        /// <summary>
        /// 图标高度
        /// </summary>
        public double ImageHeight
        {
            get { return (double)GetValue(ImageHeightProperty); }
            set { SetValue(ImageHeightProperty, value); }
        }

        public static readonly DependencyProperty ImageColorProperty = DependencyProperty.Register("ImageColor", typeof(Brush),
            typeof(BorderButton), new PropertyMetadata(Brushes.Gray, OnPropertyChanged));

        /// <summary>
        /// 图片颜色
        /// </summary>
        public Brush ImageColor
        {
            set { SetValue(ImageColorProperty, value); }
            get { return (Brush)GetValue(ImageColorProperty); }
        }

        private static void OnPropertyChanged(DependencyObject dependency, DependencyPropertyChangedEventArgs args)
        {
            BorderButton button = dependency as BorderButton;
            if (args.Property.Name.Equals("ImageColor"))
            {
                button.ImageColor = (Brush)args.NewValue;
            }
        }
    }
}
